import instance from '../util/request'


/**
 * 退出登录
 * @returns 
 */
export const logout=()=>{
  return instance.get('/user/logout')
}

/**
 * 修改密码
 * @param {*} user 
 */
export const modify_pwd=(user)=>{
  return instance.put("/user",{
    headers:{'Content-Type':'application/json'},
    data:user
  })
}
/**
 * 登录
 * @returns
 */
export const login = (user)=>{
  return instance.get('/user/login',{
    params:user
  })
}

/**
 * 查询所有用户
 * @returns
 */
export const info=(page)=>{
  return instance.get('/user',{
    params:page
  })
}

/**
 * 添加用户
 */
export const add_user=(user)=>{
  return instance.post('/user',{
    headers:{'Content-Type':'application/json'},
    data:user
  })
}
/**
 * 删除用户
 * @param {} id 
 * @returns 
 */
export const del_user=(id)=>{
  return instance.delete('/user',{
    params:{id}
  })
}

/**
 * 绑定邮箱
 * @param {*} email 
 */
export const bindEmailConfirm=(id,email,code)=>{
  return instance.post('/user/email/bind/confirm',{id,email,code})
}

/**
 * 换绑邮箱
 * @param {*} email 
 */
export const changeEmailConfirm=(id,email,code)=>{
  return instance.post('/user/email/change/confirm',{id,email,code})
}

/**
 * 重置密码
 * @param {*} email 
 */
export const resetPasswordConfirm=(data)=>{
  return instance.post('/user/email/resetPassword/confirm',data)
}

/**
 * 验证邮箱
 * @param {*} email 
 */
export const verifyEmail=(email)=>{
  return instance.post('/email/verify',{email})
}